package com.excellence.controller;

import com.excellence.datamodel.Result;
import com.excellence.pojo.Comment;
import com.excellence.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 沈秉璋
 * @ClassName CommentController
 * @Description TODO
 * @date 2024/4/8 11:39
 * @Version 1.0
 */
//@Controller
//@ResponseBody
@RestController
@RequestMapping("/api/comment")
public class CommentController {
    @Autowired
    private CommentService commentService;
    /**
     * @description: 逻辑删除
     * @author: ShenBingZhang
     * @date: 2024/4/9 21:48
     * @param: [id]
     * @return: [java.lang.Long]
     **/
    @PutMapping("/deleteByKey")
    Result deleteByKey(Long id){
        int res = commentService.deleteByKey(id);
        return Result.success(res);
    }

    @DeleteMapping("/deleteByPrimaryKey")
    Result deleteByPrimaryKey(Long id){
        int res = commentService.deleteByPrimaryKey(id);
        return Result.success(res);
    }
    @PostMapping("/insert")
    Result insert(Comment record){
        int res = commentService.insert(record);
        return Result.success(res);
    }

    @PostMapping("/insertSelective")
    Result insertSelective(Comment record){
        int res = commentService.insertSelective(record);
        return Result.success(res);
    }

    @GetMapping("/selectByPrimaryKey")
    Result selectByPrimaryKey(Long id){
        Comment res = commentService.selectByPrimaryKey(id);
        return Result.success(res);
    }

    @GetMapping("/selectAll")
    Result selectAll(){
        List<Comment> res = commentService.selectAll();
        return Result.success(res);
    }

    @PutMapping("/updateByPrimaryKeySelective")
    Result updateByPrimaryKeySelective(Comment record){
        int res = commentService.updateByPrimaryKeySelective(record);
        return Result.success(res);
    }

    @PutMapping("/updateByPrimaryKey")
    Result updateByPrimaryKey(Comment record){
        int res = commentService.updateByPrimaryKey(record);
        return Result.success(res);
    }
}
